#import <AVFoundation/AVFoundation.h>
#import <OpenAL/al.h>
#import <OpenAL/alc.h>
#import <AudioToolbox/AudioToolbox.h>
#import <AudioToolbox/ExtendedAudioFile.h>




#define	_MAX_SOUND_SOURCE	10
#define kDefaultDistance	25.0

@interface oalPlayback : NSObject
{
	ALCcontext*				context;
	ALCdevice*				device;
	
	NSMutableArray* 		_sources;
	NSMutableDictionary* 	_buffers;

	ALfloat					sourceVolume;
	BOOL					isPlaying;
	BOOL					wasInterrupted;
	
	NSURL*					_bg_music_url;
	AVAudioPlayer*			_bg_music_player;
	
	UInt32					iPodIsPlaying;
}

//@property (nonatomic, assign)	NSMutableArray* 		_sources;
//@property (nonatomic, assign)	NSMutableDictionary* 	_buffers;
@property (nonatomic, retain)    NSMutableArray*		_sources;
@property (nonatomic, retain)	NSMutableDictionary* 	_buffers;
@property (nonatomic, assign)	BOOL		isPlaying;			// Whether the sound is playing or stopped
@property (nonatomic, assign)	UInt32		iPodIsPlaying;		// Whether the iPod is playing
@property (nonatomic, assign)	BOOL		wasInterrupted;		// Whether playback was interrupted by the system

//- (void)checkForMusic;

- (void)initOpenAL;
- (void)releaseOpenAL;

- (void)loadMusic:(NSString*) filename;
- (void)setMusicVolume:(float) vol;
- (void)startMusic:(NSInteger) numberOfLoops;
- (void)stopMusic;
- (BOOL)isMusicPlaying;

- (float)getPeakMusicPower: (int) channel;
- (float)getAverangeMusicPower: (int) channel; 

- (void)loadSound:(NSString*)filename soundID:(NSInteger)sound_id;
- (void)startSound:(NSInteger)sound_id;
- (void)stopAllSound;

+ (oalPlayback*) getSharedInstance; // access to our instance

@end
